const { rm, exec, echo } = require('shelljs');
let ops = process.argv[2];
let varEnv = process.argv[3];
switch (ops) {
  case 'initial':
    echo(`${ops}-${varEnv}`);
    rm('-rf', 'm-front-common');
    exec(
      `git clone -b ${varEnv} http://guoke-deepexi:deepexi20191205@139.217.98.203/m-pla/m-front-common.git || exit 0`
    );
    break;
  case 'checkout':
    echo(`${ops}-${varEnv}`);
    exec(`git submodule foreach git checkout ${varEnv}`);
    break;
  case 'update':
    echo(`${ops} current branch`);
    exec(`git submodule foreach git pull && yarn`);
    break;
  default:
    echo('您输入的命令无效，请确认后再试！');
    break;
}
